package com.example.nio;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public class FileDemo {
    public static void main(String[] args) throws IOException {
    }

    public void createDir() throws IOException {
        Path path = Paths.get("");
        //创建新文件
        Path directories = Files.createDirectories(path);
    }

    public void copyDir() {
        Path patha = Paths.get("a");
        Path pathb = Paths.get("b");
        try {
            Files.copy(patha, pathb);
            Files.copy(patha, pathb, StandardCopyOption.COPY_ATTRIBUTES);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void deleteDir() {
        Path patha = Paths.get("a");
        try {
            Files.delete(patha);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
};

